package com.pi.service.impl;

import com.pi.common.text.Convert;
import com.pi.common.utlis.DateUtils;
import com.pi.entity.SysUser;
import com.pi.mapper.SysUserMapper;
import com.pi.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author TomFang
 * @version 1.0
 * @description: TODO
 * @date 2025/3/13 16:15
 */
@Service
public class SysUserServiceImpl implements ISysUserService {

    @Autowired
    private SysUserMapper sysUserMapper;

    /**
     * 查询用户信息
     *
     * @param userId 用户信息主键
     * @return 用户信息
     */
    @Override
    public SysUser selectSysUserByUserId(Long userId)
    {
        return sysUserMapper.selectSysUserByUserId(userId);
    }

    /**
     * 查询用户信息列表
     *
     * @param SysUser 用户信息
     * @return 用户信息
     */
    @Override
    public List<SysUser> selectSysUserList(SysUser SysUser)
    {
        return sysUserMapper.selectSysUserList(SysUser);
    }

    /**
     * 新增用户信息
     *
     * @param SysUser 用户信息
     * @return 结果
     */
    @Override
    public int insertSysUser(SysUser SysUser)
    {
        SysUser.setCreateTime(DateUtils.getNowDate());
        return sysUserMapper.insertSysUser(SysUser);
    }

    /**
     * 修改用户信息
     *
     * @param SysUser 用户信息
     * @return 结果
     */
    @Override
    public int updateSysUser(SysUser SysUser)
    {
        SysUser.setUpdateTime(DateUtils.getNowDate());
        return sysUserMapper.updateSysUser(SysUser);
    }

    /**
     * 批量删除用户信息
     *
     * @param userIds 需要删除的用户信息主键
     * @return 结果
     */
    @Override
    public int deleteSysUserByUserIds(String userIds)
    {
        return sysUserMapper.deleteSysUserByUserIds(Convert.toStrArray(userIds));
    }

    /**
     * 删除用户信息信息
     *
     * @param userId 用户信息主键
     * @return 结果
     */
    @Override
    public int deleteSysUserByUserId(Long userId)
    {
        return sysUserMapper.deleteSysUserByUserId(userId);
    }
}
